{% extends "profiles/base.html" %}

{% load i18n %}
{% load pagination_tags %}
{% load avatar_tags %}
{% load humanize %}
{% load profile_tags %}

{% block head_title %}{% blocktrans %}All Profiles{% endblocktrans %}{% endblock %}

{% block body %}
    <h1>{% trans "Profiles" %}</h1>
    
    <form method="GET" action="">
        <input type="text" name="search" value="{{ search_terms }}" />
        <input type="submit" value="Search" />
        {% if search_terms %}
            <a href="{% clear_search_url request %}">Clear Search Terms</a>
        {% endif %}
    </form>
    
    {% if users %}
        <p>{% trans "Order by:" %}
            {% ifequal order 'date' %}
                <a href="{% url profile_list %}?order=name">{% trans "Name" %} &uarr;</a>
            {% else %}
                <a href="{% url profile_list %}?order=date">{% trans "Date" %} &darr;</a>
            {% endifequal %}
        </p>
        
        {% autopaginate users%}
        
        {% ifequal order 'date'  %}
            {% regroup users by date_joined.date as users_by_date_joined %}
            
            {% for date in users_by_date_joined %}
                <h2 class="join_date">{{ date.grouper|naturalday:_("MONTH_DAY_FORMAT")|capfirst }}</h2>
                
                {% for user in date.list %}
                    {% show_profile user %}
                {% endfor %}
            {% endfor %}
        {% else %}
            {% for user in users %}
                {% show_profile user %}
            {% endfor %}
        {% endifequal %}
        
        {% paginate %}
        
       {% else %}
           <p>No profile were found.</p>
      {% endif %}
{% endblock %}